package com.ctgu.蓝桥杯真题.B组2018;

import java.io.*;
import java.util.*;

/**
 * @author: Backdiy
 * @data: 2021/4/13 12:40
 * @desc:
 */
public class H日志统计 {
    static P[] ps = new P[100010];

    public static void main(String[] args) throws IOException {
        int n = IO.nextInt();
        int d = IO.nextInt();
        int k = IO.nextInt();
        for (int i = 0; i < n; i++) {
            ps[i] = new P(IO.nextInt(), IO.nextInt());
        }
        Arrays.sort(ps, 0, n);
        Map<Integer, ArrayList<Integer>> ial = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            if (ial.containsKey(ps[i].id)) {
                ArrayList<Integer> integers = ial.get(ps[i].id);
                integers.add(ps[i].ts);
                ial.put(ps[i].id, integers);
            } else {
                ArrayList<Integer> integers = new ArrayList<>();
                integers.add(ps[i].ts);
                ial.put(ps[i].id, integers);
            }
        }
        for (Map.Entry<Integer, ArrayList<Integer>> i :
                ial.entrySet()) {
            ArrayList<Integer> value = i.getValue();
            Integer key = i.getKey();
//            System.out.println(""+key+value);
            int sum = 0;
            int l = 0, r = 0, len = value.size();
            while (l <= r && r < len) {
                sum++;
                if (sum >= k) {
                    if (value.get(r) - value.get(l) < d) {
                        IO.out.println(key);
                        break;
                    }else{
                        l++;
                        sum--;
                    }
                }
                r++;
            }
        }
        IO.out.flush();
    }

    static class P implements Comparable<P> {
        int ts, id;

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            P p = (P) o;
            return ts == p.ts && id == p.id;
        }

        @Override
        public String toString() {
            return "P{" +
                    "ts=" + ts +
                    ", id=" + id +
                    '}';
        }

        @Override
        public int hashCode() {
            return Objects.hash(ts, id);
        }

        public P(int ts, int id) {
            this.ts = ts;
            this.id = id;
        }

        @Override
        public int compareTo(P o) {
            if (this.id == o.id)
                return this.ts - o.ts;
            return this.id - o.id;
        }
    }

    static class IO {
        static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        static public int nextInt() throws IOException {
            in.nextToken();
            return (int) in.nval;
        }

        static public String readLine() throws IOException {
            return read.readLine();
        }
    }
}
